package com.proyecto.xpdroid.util;

import java.io.InputStream;
import java.util.Properties;
//import org.apache.log4j.Logger;

/**
 * <dl>
 * <dt><b>Class Description:</b>
 * <dd>This class loads the configuration info from the properties files.
 * </dl>
 * 
 * @author Sasi
 * @version $Version Control Number: /aacorn/ws_branch/1 $ <br>
 *          $Date: Friday, May 04, 2007 @ 10:56 $ <br>
 *          $Last modified by:$
 */
public class ConfigUtil { 

	private static final String PROP = "util.properties";

	private static ConfigUtil _wsConfigUtil;

	private static Properties _properties;

	//private static final Logger _logger = Logger.getLogger(ConfigUtil.class);

	static {
		_wsConfigUtil = new ConfigUtil();
	}

	/**
	 * This method avoids to get instance of this static class.
	 */
	private ConfigUtil() {

		try {
			_properties = loadProperties(PROP);
		} catch (Exception e) {
			// do nothing;
		}

	}

	/**
	 * This method getInstance of util object.
	 * 
	 * @return WSConfigUtil
	 */
	static public ConfigUtil getInstance()

	{

		return _wsConfigUtil;
	}

	/**
	 * @param propFile
	 *            String
	 * @return String
	 * @throws WSException
	 *             WSException
	 */
	private static Properties loadProperties(String propFile)

	{

		try {
			InputStream inputStream = ConfigUtil.class.getClassLoader()
					.getResourceAsStream(propFile);
			_properties = new Properties();
			_properties.load(inputStream);
		} catch (Exception e) {

		}
		return _properties;
	}

	/**
	 * @param key
	 *            String
	 * @return String
	 */
	public String getPropertyValue(String key)

	{

		return _properties.getProperty(key);

	}
}
